package leetcode_600;

import java.util.ArrayList;
import java.util.List;
class Node {
    public int val;
    public List<Node> children;

    public Node() {}

    public Node(int _val,List<Node> _children) {
        val = _val;
        children = _children;
    }
}
/**
 *@author 周杨
 *NaryTreePreorderTraversal_589 先序遍历一颗多叉树
 *describe:递归 AC 99%
 *2018年9月17日 上午10:58:47
 */
public class NaryTreePreorderTraversal_589 {
	public List<Integer> preorder(Node root) {
        List<Integer> res=new ArrayList<Integer>();
        if(root==null)
        	return res;
        help(root,res);
        return res;
    }
	
	public void help(Node root,List<Integer> list) {
		list.add(root.val);
		for(Node node:root.children) {
			help(node,list);
		}
	}
}
